#include "MyScrollAreaWidget.h"
#include <MyItem.h>

MyScrollAreaWidget::MyScrollAreaWidget(QWidget* parent)
	: QWidget(parent)
	, ui(new Ui::MyScrollAreaWidgetClass())
{
	ui->setupUi(this);
	QVBoxLayout* lay = new QVBoxLayout(ui->widget);
	QColor color;
	for (int i(0); i < 10; ++i) {
		color.setRed(0);
		color.setGreen(50);
		color.setBlue(0);
		MyItem* item = new MyItem(color, i + 1);
		lay->addWidget(item);
		// ui->scrollAreaWidgetContents显示需要可见的区域，当可见区域大于MyScrollAreaWidget的尺寸时，会出现滑动条
		ui->scrollAreaWidgetContents->resize(ui->widget->size());
	}
}

MyScrollAreaWidget::~MyScrollAreaWidget()
{
	delete ui;
}
